<template>
  <div class="list-box">
    <div v-if="!MyForm.show" class="add" @click="addItem">
      新增
    </div>
    <div v-if="!MyForm.show" class="table-list">
      <CMytTable/>
    </div>
    <div v-if="MyForm.show" class="form-list">
      <SimpleForm @close="formClose"/>
    </div>
  </div>

  <!--  <div class="btn-list flex-center">-->
  <!--    <BtnGroup close-name="还原" submit-name="保存" @close="getData" @submit="save"></BtnGroup>-->
  <!--  </div>-->
</template>

<script setup>
import CMytTable from "@/components/my-table/index.vue";
import {reactive} from "@vue/reactivity";
import {onMounted} from "@vue/runtime-core";
import {addTableConfig} from "@/components/customs/dialog-set/component/cpu-list-set/data";
import {provide} from "vue";
import SimpleForm from "@/components/customs/simple-form/index.vue";

const Self = reactive({
  type: 1,
  typeChange: (index) => {
    Self.type = index;
  },

});
const MyTable = reactive({
  onSearch: null,
});
const MyForm = reactive({
  url: "cpu",
  show: false,
  formDatas: {},
  datas: [
    {
      type: "input",
      name: "name",
      title: "名称",
    },
    {
      type: "input",
      name: "sm",
      title: "说明",
    },
    {
      type: "input",
      name: "pid",
      title: "pid",
    },
    {
      type: "input",
      name: "zb",
      title: "占比",
    },
  ]
});
const addItem = () => {
  MyForm.formDatas = {};
  MyForm.show = true;
};
const formClose = () => {
  MyForm.formDatas = {};
  MyForm.show = false;
  MyTable.getDatas();
  console.log(MyTable);
};
onMounted(() => {

});

provide("MyTable", MyTable);
provide("MyForm", MyForm);
addTableConfig(MyTable, MyForm, Self);

</script>

<style lang="less" scoped>
@import "./index.less";
</style>
